package com.apes.crm.vip.vipInfo;

import com.apes.crm.vip.base.VipLevel;
import com.apes.crm.vip.base.VipLiveness;
import com.apes.crm.vip.base.VipType;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.Party;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

/**
 * 功能：会员信息
 *
 * @author HuJianlin
 * @create 2018-03-15 16:00
 */
@Getter
@Setter
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = VipInfo.CONST_TABLE_NAME)
public class VipInfo extends Model {
    public static final String CONST_TABLE_NAME = "crm_vip_info";

    @Id
    @Column(name = "id", length = 16)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "会员信息", padding = 10)
    @Comment("会员编码")
    private String id;  //会员编码

    @OneToOne(optional = false)
    @JoinColumn(name="party_id", referencedColumnName="ID")
    @Comment("当事人编码")
    private Party party; //当事人

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vip_type_id", referencedColumnName = "id")
    @Comment("会员类型编码")
    private VipType vipType; //会员标签类型

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vip_level_id", referencedColumnName = "id")
    @Comment("会员级别编码")
    private VipLevel vipLevel; //会员级别

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vip_liveness_id", referencedColumnName = "id")
    @Comment("会员活跃度编码")
    private VipLiveness vipLiveness;  //会员活跃度

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "register_way", referencedColumnName = "id")
    @Comment("注册途径")
    private Enumeration registerWay; //注册途径(store: 门店；officialWeb：官网；WeChat：微信；app：手机App)

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "reg_dept_id", referencedColumnName = "id")
    @Comment("注册部门编码")
    private Dept regDept; //注册部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "serve_dept_id", referencedColumnName = "id")
    @Comment("服务部门")
    private Dept serveDept; //服务部门

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vip_state_id", referencedColumnName = "id")
    @Comment("会员状态")
    private Enumeration vipState; //会员状态（freezing：冻结; opening：启用） -- InsuranceFreeze：保险冻结(未使用)

}
